import 'package:flutter/material.dart';

class AnimatedIconPage extends StatefulWidget {
  const AnimatedIconPage({super.key});

  @override
  State<AnimatedIconPage> createState() => _AnimatedIconPageState();
}

class _AnimatedIconPageState extends State<AnimatedIconPage>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(milliseconds: 1000),
      vsync: this,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('AnimatedIcon'),
      ),
      body: Center(
        child: Column(
          children: [
            AnimatedIcon(
              icon: AnimatedIcons.close_menu,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.arrow_menu,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.add_event,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.ellipsis_search,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.event_add,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.home_menu,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.list_view,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.menu_arrow,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.menu_close,
              progress: _controller,
              size: 40,
            ),
            AnimatedIcon(
              icon: AnimatedIcons.menu_home,
              progress: _controller,
              size: 40,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          if (_controller.isCompleted) {
            _controller.reverse();
          } else {
            _controller.forward();
          }
        },
        child: const Icon(Icons.play_arrow),
      ),
    );
  }
}
